#include<bits/stdc++.h>
#define XH(i,a,b) for(int i=a;i<b;++i)
#define XXH(i,a,b) for(int i=a-1;i>=b;--i)
#define LL long long
using namespace std;
int tmpINT; string tmpSTRING; char tmpCHAR; double tmpDOUBLE; LL tmpLONGLONG;

int main(){
	int n;scanf("%d", &n);
	int a[n];
	XH(i , 0 , n)scanf("%d", &a[i]);
	int ans = -1;
	XH(i , 0 , n){		
		int mymax = a[i];
		if(a[i]>ans){
			ans = a[i];
		}
		XXH(j , i , 0){
			if(a[j]<mymax){
				mymax = a[j];				
			}
			tmpINT = mymax * (i-j+1);
			ans = max(tmpINT,ans);
			if(mymax*(i+1)<=ans)break;
		}
	}

	printf("%d\n", ans);
	
	return 0;
}